from django.http import HttpResponseRedirect, HttpResponse, JsonResponse
from django.shortcuts import render
from django.core.cache import cache  # 引入缓存模块


# Create your views here.
def home(request):
    return render(request, 'admin/home.html')


def index(request):
    # return HttpResponse('<script>location.href=\'./static/index.html\'</script>')
    return HttpResponse(
        '<script>location.href=\'http://service-rc19bpno-1251354949.gz.apigw.tencentcs.com/release/tiyuan\'</script>')


def get_user(request):
    stu_card = request.GET.get('stu_card')

    if cache.has_key(f'user:{stu_card}'):
        data = cache.get(f'user:{stu_card}')
        return JsonResponse(data, safe=False)
    return JsonResponse({}, safe=False)
